package com.demo;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by Administrator on 2018/9/19.
 */
public class SimpleFactory {
    public static Weapon getWeapon() {
        try {
            Properties pro = new Properties();
            pro.load(SimpleFactory.class.getClassLoader().getResourceAsStream("beans.properties"));
            String w = (String) pro.get("weapon");
            Weapon weapon = (Weapon) Class.forName(w).newInstance();
            return weapon;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
//        return new Knife();
    }
}
